/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;

/**
 *
 * @author Keith
 */
@Stateless
public class WhiteboardBean implements WhiteboardBeanLocal {

    @Override
    public String getNotes() {
        String res = "";
        try {
            BufferedReader in = new BufferedReader(new FileReader("whiteboard.txt"));
            String line = "";
            while((line = in.readLine()) != null){
                res += line;
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(WhiteboardBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ioe){
            Logger.getLogger(WhiteboardBean.class.getName()).log(Level.SEVERE, null, ioe);
        }
        return res;
    }

    @Override
    public boolean saveNotes(String s) {
        try {
            BufferedWriter out = new BufferedWriter(new FileWriter("whiteboard.txt"));
            out.write(s);
            out.close();
        } catch (IOException ioe) {
            Logger.getLogger(WhiteboardBean.class.getName()).log(Level.SEVERE, null, ioe);
            return false;
        }
        return true;
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
}
